<?php
// +----------------------------------------------------------------------
// | ManniuRead
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://manniuyun.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: heitao <read@manniuyun.com>
// +----------------------------------------------------------------------

namespace app\mall\model;

use think\Model;

class MallPayment extends Model{
	// 支付配置 - 获取器
    protected function getPayConfigAttr($value) {
    	$data = '';
		$value = mn_string2array($value);
		if(is_array($value)){
			foreach ($value as $k => $v) {
				foreach ($v as $k2 => $v2) {
	    			$data .= $k2.'|'.$v2."\r\n";
	    		}
			}
		}
    	return $data ? $data : $value;
    }

    /**
     * 支付配置 - 修改器
     */
    public function setPayConfigAttr($value){
        $data = explode("\r\n", $value);
        $params = [];
        if($data){
        	foreach ($data as $k => $v) {
        		if(!empty($v)){
        			$param = explode('|', $v);
        			$params[][$param[0]] = $param[1];
        		}
        	}
        }
        $params = count($params) ? mn_array2string($params) : null;
        return $params;
    }
}